/**
* @Description: 用户信息
* @Author: 王燕欣
* @Date: 2024-10-14 19:31
*/
import FlutterBridge from "@/utils/FlutterBridge";


const user = {
  state: {
    token: '',
    rightSideSearchGis: null, // realtime 实时监控视频 flutter回调状态
    rightSideSearchHistoryTrack: null, // historyTrack flutter 回调，轨迹回放 
    rightSideSearchIndicatorMonitoring: null, // indicatorMonitoring  flutter 回调，指标
  },

  mutations: {
    /**
    * @Description: 设置token方法
    * @Author: 王燕欣
    * @Date: 2024-10-14 19:46
    */
    SET_TOKEN: (state, token) => {
      console.log('SET_TOKEN----res-', token);
      state.token = token;
    },
    /**
    * @Description: 右上角搜索 gis监控
    * @Author: 王燕欣
    * @Date: 2025-01-20 14:38
    */
    RIGHT_SIDE_SEARCH_GIS: (state, params) => {
      // console.log('RIGHT_SIDE_SEARCH_GIS--右上角搜索--res-', params);
      state.rightSideSearchGis = params;
    },
    RIGHT_SIDE_SEARCH_HISTORY_TRACK: (state, params) => {
      // console.log('RIGHT_SIDE_SEARCH_HISTORY_TRACK--右上角搜索--res-', params);
      state.rightSideSearchHistoryTrack = params;
    },
    RIGHT_SIDE_SEARCH_INDICATOR: (state, params) => {
      // console.log('RIGHT_SIDE_SEARCH_INDICATOR--右上角搜索--res-', params);
      state.rightSideSearchIndicatorMonitoring = params;
    },

  },
  actions: {
    /**
    * @Description: 刷新token
    * @Author: 王燕欣
    * @Date: 2024-10-15 14:13
    */
    async refreshToken() {
      console.log('刷新token--refreshToken--->')
      FlutterBridge.RequestFlutterBridge('getTokenFromFlutter');// 从flutter获取token
      setTimeout(() => {
        return user.state.token
      }, 1000)
    },
  }
}

export default user
